package coredb;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/** Entity class for Transaction
 *
 * @author New
 */
@Entity
@Table(name = "transaction")
@NamedQueries({
    @NamedQuery(name = "Transaction.findByAccno", query = "SELECT t FROM Transaction t WHERE t.accno = :accno"),
    @NamedQuery(name = "Transaction.findAll", query = "SELECT t FROM Transaction t"),
    @NamedQuery(name = "Transaction.findByTimeoftxn", query = "SELECT t FROM Transaction t WHERE t.timeoftxn = :timeoftxn"),
    @NamedQuery(name = "Transaction.findByTxnid", query = "SELECT t FROM Transaction t WHERE t.txnid = :txnid"),
    @NamedQuery(name = "Transaction.findByTypeoftxn", query = "SELECT t FROM Transaction t WHERE t.typeoftxn = :typeoftxn"),
    @NamedQuery(name = "Transaction.findByAmount", query = "SELECT t FROM Transaction t WHERE t.amount = :amount")})
public class Transaction implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @Column(name = "timeoftxn")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeoftxn;
    @Id
    @Basic(optional = false)
    @Column(name = "txnid")
    private String txnid;
    @Basic(optional = false)
    @Column(name = "typeoftxn")
    private String typeoftxn;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "amount")
    private Double amount;
    @JoinColumn(name = "accno", referencedColumnName = "accno")
    @ManyToOne(optional = false)
    private Account accno;

    /**
     *
     */
    public Transaction() {
    }

    /**
     *
     * @param txnid
     */
    public Transaction(String txnid) {
        this.txnid = txnid;
    }

    /**
     *
     * @param txnid
     * @param timeoftxn
     * @param typeoftxn
     */
    public Transaction(String txnid, Date timeoftxn, String typeoftxn) {
        this.txnid = txnid;
        this.timeoftxn = timeoftxn;
        this.typeoftxn = typeoftxn;
    }

    /**
     *
     * @return 
     */
    public Date getTimeoftxn() {
        return timeoftxn;
    }

    /**
     *
     * @param timeoftxn
     */
    public void setTimeoftxn(Date timeoftxn) {
        this.timeoftxn = timeoftxn;
    }

    /**
     *
     * @return
     */
    public String getTxnid() {
        return txnid;
    }

    /**
     *
     * @param txnid
     */
    public void setTxnid(String txnid) {
        this.txnid = txnid;
    }

    /**
     *
     * @return
     */
    public String getTypeoftxn() {
        return typeoftxn;
    }

    /**
     *
     * @param typeoftxn
     */
    public void setTypeoftxn(String typeoftxn) {
        this.typeoftxn = typeoftxn;
    }

    /**
     *
     * @return
     */
    public Double getAmount() {
        return amount;
    }

    /**
     *
     * @param amount
     */
    public void setAmount(Double amount) {
        this.amount = amount;
    }

    /**
     *
     * @return
     */
    public Account getAccno() {
        return accno;
    }

    /**
     *
     * @param accno
     */
    public void setAccno(Account accno) {
        this.accno = accno;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (txnid != null ? txnid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Transaction)) {
            return false;
        }
        Transaction other = (Transaction) object;
        if ((this.txnid == null && other.txnid != null) || (this.txnid != null && !this.txnid.equals(other.txnid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "coredb.Transaction[ txnid=" + txnid + " ]";
    }
    
}
